package com.kaishengit.web;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.dao.DocumentDao;
import com.kaishengit.dao.ProjectDao;
import com.kaishengit.entity.Document;
import com.kaishengit.entity.Project;

public class DocumentServlet extends HttpServlet {

	

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int projectid = 0;
		projectid =	Integer.parseInt(request.getParameter("projectid"));
		Project p = new Project();
		ProjectDao pdao = new ProjectDao();
		p = pdao.findByProjectId(projectid);
		List<Document> dlist = new ArrayList<Document>();
		DocumentDao ddao = new DocumentDao();
		dlist =  ddao.findByProjectId(projectid);
		request.setAttribute("dlist", dlist);
		request.setAttribute("project", p);
		request.getRequestDispatcher("WEB-INF/views/document.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}
